/*
 * @Author       : NaN 353362604@qq.com
 * @Date         : 2023-01-12 09:35:49
 * @LastEditTime : 2023-06-27 13:52:29
 * @LastEditors  : NaN 353362604@qq.com
 * @FilePath     : \AdminStration\src\Common\Router\MenuNav\TwoRouter\Organization.jsx
 * @Description  :
 */
import { API_LIST } from '../../../Api/Api'
import { commonTableList } from '../Common/common'
import { DelDataButton, OpenThrTouter } from '../Common/options'
import { ProjectList } from '../Common/Conversion'

export const Organization = async ({ OptionsEvent, oneData, Permission, actionRef }) => {
    const { hostname } = window.location
    const projectUuid = await ProjectList()
    let data = {
        pageSize: 10,
        // hideInSearch: !hostname.includes('jszx'),
        params: { parentOrganizationUuid: oneData.uuid },
        get: API_LIST([oneData.uuid])['getOrganizationRelationGetOrgListByParentOrgUuid'],
        options: [
            Permission.findIndex(v => v.uuid === 'c9694e0b-760c-4ff8-823e-80ebe4460703') !== -1 && (
                <OpenThrTouter
                    title="添加从属机构"
                    type="primary"
                    icon="add"
                    modal="SelectModal"
                    OptionsEvent={OptionsEvent}
                    other={{
                        page: 'Organization',
                        actionRef,
                        Permission,
                        twoData: oneData,
                    }}
                />
            ),
        ],
        columns: [
            { ...commonTableList.tableName, title: '组织机构' },
            {
                ...commonTableList.projectUuid,
                valueEnum: projectUuid,
                hideInAdded: true,
                hideInModify: true,
                hideInTable: true,
                hideInSearch: !hostname.includes('jszx'),
                order: 3,
            },
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 220,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    return [
                        Permission.findIndex(v => v.uuid === '1506d480-fb0a-4ff5-bb93-14e4f72e5946') !== -1 && (
                            <DelDataButton
                                OptionsEvent={OptionsEvent}
                                key="del"
                                title="删除"
                                url="OrganizationRelation"
                                uuid={record.uuid}
                            />
                        ),
                    ]
                },
            },
        ],
    }
    return data
}
